#include "Type.h"
#include "MemEx.h"


void reversal_data_4B(UINT8 *pData,UINT16 l_max_index)
{
    UINT8 l_i,l_p;
    UINT16 l_index =0;
    UINT8* l_ptr;
    l_ptr = pData;
    while (l_index < l_max_index)
    {
        for(l_i = 0;l_i < 2;l_i ++)
    	{
            l_p = l_ptr[l_i];
    		l_ptr[l_i] = l_ptr[4 - l_i -1];
    		l_ptr[4 - l_i -1] = l_p;
    	}
    	l_ptr += 4;
    	l_index ++ ;
    	
    }
    return;   	
}

void reversal_data(unsigned char *pbData, long dwLen) 
{
	unsigned char l_swap;
	unsigned long l_i;

	for(l_i = 0; l_i < dwLen / 2; l_i++) 
	{
		l_swap = pbData[l_i];
		pbData[l_i] = pbData[dwLen - l_i - 1];
		pbData[dwLen - l_i - 1] = l_swap;
	}
}

unsigned int MemStrLen(unsigned char  *pD, unsigned int MaxLen)
{
	register unsigned int nLen = 0;

	while(*pD && (nLen < MaxLen))
	{
		nLen++;
		pD++;
	}

	return (nLen);
}

unsigned int MemIsFillBy(unsigned char  *pD, unsigned char fill, unsigned int MaxLen)
{
	register unsigned int i = 0;
	register unsigned char n = fill;

	for(i = 0; i < MaxLen; i++)
	{
		if(pD[i] != n) return (0);	
	}

	return (1);
}
